#ifndef COOLPOOL_SIMULATION_SIMOBJECTS_RIGIDBODYFRICTION_H_
#define COOLPOOL_SIMULATION_SIMOBJECTS_RIGIDBODYFRICTION_H_

#include <MatrixTools.h>

#include "Ball.h"
#include "Collision.h"
#include "Constants.h"
#include "ObjectTypes.h"
#include "Rectangle.h"
#include "RigidBody.h"

namespace coolpool
{
	// Adds friction to collision impulse, which was already resolved.
	// For computing it needs the size of the normal impulse which was applied.
	void addFrictionToImpulse(const Collision * collision, RigidBody * body1, RigidBody * body2, double normal_impulse_size);

	// Adds rolling friction to the collision impulse.
	// It is called from within the addFrictionToImpulse method.
	void addRollingFriction(Ball * ball, const math_tools::Vector3D & collision_normal, const math_tools::Vector3D & ball_r, RigidBody * surface, double normal_impulse_size);

	inline bool equalsZero(double d)
	{
		return d > -EPSILON && d < EPSILON;
	}
}

#endif
